import request from '@/utils/request'
import { praseStrEmpty } from '@/utils/sg'
// 查询用户列表
export function listUser(query) {
  return request({
    url: '/system/user/list',
    method: 'get',
    params: query
  })
}
// 查询用户详细
export function getUser(userId) {
  return request({
    url: '/system/user/' + praseStrEmpty(userId),
    method: 'get'
  })
}

// 新增用户
export function addUser(data) {
  return request({
    url: '/system/user',
    method: 'post',
    data: data
  })
}
// 删除用户
export function delUser(id) {
  return request({
    url: '/driver/api/v1/info/deleteUser/',
    params: {
      id: id
    },
    method: 'post'
  })
}
// 用户密码重置
export function resetUserPwd(userId, password) {
  const data = {
    userId,
    password
  }
  return request({
    url: '/system/user/resetPwd',
    method: 'put',
    data: data
  })
}

// 修改用户
export function updateUser(id,phone,name,idCard,password,position,sex) {
  return request({
    url: '/driver/api/v1/info/updateUser',
    method: 'post',
    params:{
      id:id,
      phone:phone,
      name:name,
      idCard:idCard,
      password:password,
      position:position,
      sex:sex
    }
  })
}
// 用户状态修改
export function changeUserStatus(id,status) {
  return request({
    url: '/admin/user/changeUserStatus',
    method: 'post',
    params:{
      id:id,
      status:status
      
    }
  })
}

export function searchUser(phone,name,page,size) {
  return request({
    url: '/driver/api/v1/info/searchDriver',
    method: 'post',
    params:{
      phone:phone,
      name:name,
      page:page,
      size:size,
    }
  })
}
export function getUserById(id) {
  return request({
    url: '/driver/api/v1/info/getUserById',
    method: 'post',
    params:{
      id:id
    }
  })
}

export function getUserByToken() {
  return request({
    url: '/driver/api/v1/info/getUserByToken',
    method: 'get',
  })
}

//保存管理员信息
export function saveDriverInfo(DriverInfo) {
  return request({
    url:"/driver/api/v1/info/saveDriverInfo",
    method:"put",
    data : DriverInfo
  });
}